import { http } from "@/utils/http";
import { baseUrlApi } from "../utils";

type Result = {
  status: number;
  msg: string;
  success: boolean;
  data?: string;
};

type KeyValue = {
  key: string;
  value: string;
};

type ResultKeyValue = {
  success: boolean;
  data?: Array<KeyValue>;
};

type ResultDepartment = {
  success: boolean;
  data?: {
    list: Array<any>;
    totalCount: number;
  };
};

type SortNoResult = {
  status: number;
  msg: string;
  success: boolean;
  data?: number;
};

/** 获取班级下拉框数据源 */
export const GetAllClass = () => {
  return http.request<ResultKeyValue>("get", baseUrlApi("/ZSClass/GetAll"));
};

/** 获取全部班级 */
export const ClassGetAll = (params?: object) => {
  return http.request<ResultDepartment>("get", baseUrlApi("/ZSClass/GetAll"), {
    params
  });
};

/** 根据机构Id获取教师列表 */
export const ClassGetPage = (params?: object) => {
  return http.request<ResultDepartment>("get", baseUrlApi("/ZSClass/GetPage"), {
    params
  });
};

//获取最新的班级编号
export const GetNewClassId = (params?: object) => {
  return http.request<SortNoResult>(
    "get",
    baseUrlApi("/ZSClass/GetNewClassId"),
    {
      params
    }
  );
};

//保存
export const ClassSave = (data?: object) => {
  return http.request<Result>("post", baseUrlApi("/ZSClass/Save"), {
    data
  });
};

//修改班级
export const ClassUpdate = (data?: object) => {
  return http.request<Result>("post", baseUrlApi("/ZSClass/Update"), {
    data
  });
};

//删除
export const ClassDelete = (params?: string) => {
  return http.request<Result>("post", baseUrlApi("/ZSClass/Delete?" + params));
};
